<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <ul class="dian">
        <li class="sm" style="background-color: red;"></li>
        <li class="sm" style="background-color: seagreen;"></li>
        <li class="sm" style="background-color: #000;"></li>
    </ul>
    <ul>
        <li class="xm">新闻</li>
        <li class="xm">娱乐</li>
        <li class="xm">体育</li>
        <li class="xm">电影</li>
        <li class="xm">音乐</li>
        <li class="xm">旅游</li>
    </ul>
</body>

</html>
<script>
    var bg = document.querySelector(".dian").querySelectorAll("li")
    console.log(bg);
    for (let i = 0; i < bg.length; i++) {
        bg[i].onclick = function () {
            document.body.style.backgroundColor = this.style.backgroundColor
        }
    }
</script>
<style>
    li {
        list-style: none;
        width: 50px;
        height: 20px;
        font-size: 8px;
        border: 1px solid green;
        color: green;
        text-align: center;
    }

    ul {
        display: flex;
    }

    .sm {
        width: 10px;
        height: 10px;
        margin-right: 10px;
    }
</style>